#ifndef  M_USART_H
#define  M_USART_H
#include "stm32f10x.h"
#include <stdio.h>

typedef enum { false = 0, true = !false } bool; 

#ifdef __GNUC__
  /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
     set to 'Yes') calls __io_putchar() */
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */


#define USARTy                   USART3
#define USARTy_GPIO              GPIOB
#define USARTy_CLK               RCC_APB1Periph_USART3
#define USARTy_GPIO_CLK          RCC_APB2Periph_GPIOB
#define USARTy_RxPin             GPIO_Pin_11
#define USARTy_TxPin             GPIO_Pin_10
#define USARTy_Tx_DMA_Channel    DMA1_Channel2
#define USARTy_Tx_DMA_FLAG       DMA1_FLAG_TC2
#define USARTy_Tx_DMA_IRQn       DMA1_Channel2_IRQn
#define USARTy_Tx_DMA_IRQhandler DMA1_Channel2_IRQHandler

#define USARTy_Rx_DMA_Channel    DMA1_Channel3
#define USARTy_Rx_DMA_FLAG       DMA1_FLAG_TC3 
#define USARTy_Rx_DMA_IRQn       DMA1_Channel3_IRQn
#define USARTy_Rx_DMA_IRQhandler DMA1_Channel3_IRQHandler
#define USARTy_DR_Base           0x40004804
#define USARTy_IRQn              USART3_IRQn

#define    RxBufferSize   27


//#define WITH_USB
#define WITH_USART


void My_Usart_Init();
void USART_SENTDATA(char *data_buffer, u8 Nb_bytes);


bool iNEMO_SENDCOMMAND( char *data_buffer, u8 Nb_Bytes );
#endif